package mrusanov.sounds

class SpriteSoundConfiguration(private[sounds] val attackSuccess:Option[Sound], private[sounds] val attackMiss:Option[Sound],
                               private[sounds] val death:Option[Sound], private[sounds] val hit:Option[Sound],
                               private[sounds] val attackSpriteCorrection:Int) {

  def playAttackSoundIfNeeded(success:Boolean, index:Int) {
     if (index == attackSpriteCorrection) {
       if (success) playSound(attackSuccess)
       else playSound(attackMiss)
     }
  }

  def playHitSound() {
    playSound(hit)
  }

  def playDeathSound() {
    playSound(death)
  }

  private def playSound(sound:Option[Sound]) {
    sound.foreach(_.play())
  }
}

